package com.share.admin.web;

import com.share.config.log.spel.LogSpel;
import com.share.admin.model.db.OssFile;
import com.share.admin.service.IOssFileService;
import com.share.common.common.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @autor 01401061 - 孙艳强
 * @date 2020/12/3 17:40
 */
@Slf4j
@Api("文件模块")
@RestController
@RequestMapping("oss")
public class OssFileController {
    @Autowired
    private IOssFileService iOssFileService;

    /**
     * @param code
     * @return
     * @PreAuthorize("hasAuthority('system:user:query')") 是一个el表达式, 需要内置解析
     */
    @PreAuthorize("hasAuthority('system:user:query')")
    @ApiOperation("查询用户文件")
    @RequestMapping("/listUserFile")
    @LogSpel(content = "code为' + #code + '的角色获取应用'")
    public Result listUserFile(String code) {
        List<OssFile> list = iOssFileService.listFile(code);
        return Result.success(list);
    }

    @ApiOperation("查询通用文件")
    @RequestMapping("/listCommonFile")
    public Result listCommonFile(String code) {
        List<OssFile> list = iOssFileService.listFile(code);
        return Result.success(list);
    }
}
